﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 坦克大战
{
    enum 方向
    {
        上,下,左,右
    }
    class 移动物体:GameObject
    {
        
        private Object _lock = new object(); 
        public Bitmap B上 { get; set; }
        public Bitmap B下 { get; set; }
        public Bitmap B左 { get; set; }
        public Bitmap B右 { get; set; }
        public int I速度 { get; set; }
        public 方向 方向;
        public 方向 F方向 { get { return 方向; }
            set
            {
                方向 = value;
                Bitmap bmp = null;
                switch (方向)
                {
                    case 方向.上:
                        bmp = B上;
                        break;
                    case 方向.下:
                        bmp = B下;
                        break;
                    case 方向.左:
                        bmp = B左;
                        break;
                    case 方向.右:
                        bmp = B右;
                        break;
               
                }
             
                    lock (_lock)
                    {
                    try
                    {
                        i宽 = bmp.Width;
                        i高 = bmp.Height;
                    }
                    catch (Exception)
                    {

                      
                    }
                        
                    }
                   
                
           
                

            }
        }

        public override Image 得到图像()
        {
            Bitmap b = null;
            switch (F方向)
            {

                case 方向.上:
                    b = B上;
                    break;
                case 方向.下:
                    b = B下;
                    break;
                case 方向.左:
                    b = B左;
                    break;
                case 方向.右:
                    b = B右;
                    break;


            }
            b.MakeTransparent(Color.Black);
            return b;
        }

        public override void 画自身()
        {
            lock (_lock)
            {
                base.画自身();
            } 
        }
    }
}
